home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gui / DesignerV1_53.lha / Designer / ToggleDemo / ToggleDemo.s < prev    next >
Text File  |  1995-04-28  |  6KB  |  212 lines

  1. ; Compile me to get full executable
  2. ; Does not support keyboard short cuts yet
  3.  
  4.  
  5.     include    toggledemowin.i
  6.  
  7. GT_ReplyIMsg             EQU    -78
  8. GT_GetIMsg               EQU    -72
  9. WaitPort                 EQU    -384
  10. ItemAddress              EQU    -144
  11. GT_BeginRefresh          EQU    -90
  12. GT_EndRefresh            EQU    -96
  13. CloseScreen              EQU    -66
  14. GT_SetGadgetAttrsA       EQU    -42
  15. RemoveGList              EQU    -444
  16. AddGList                 EQU    -438
  17. RefreshGList             EQU    -432
  18.  
  19. start
  20.  
  21.     jsr     OpenLibs
  22.     tst.l   d0
  23.     bne     NoLibs
  24.     jsr     MakeImages
  25.     tst.l   d0
  26.     bne     NoImages
  27.     jsr     OpenMainWindowWindow
  28.     tst.l   d0
  29.     bne     NoWindow
  30. WaitHere:
  31.     move.l  MainWindow,a1               ; Get win address
  32.     move.l  86(a1),a2                   ; Get message port
  33.     move.l  a2,a0
  34.     move.l  _SysBase,a6
  35.     jsr     WaitPort(a6)
  36.     move.l  _GadToolsBase,a6
  37.     move.l  a2,a0
  38.     jsr     GT_GetIMsg(a6)
  39.     tst.l   d0
  40.     beq     WaitHere
  41.     move.l  d0,a1
  42.     move.l  20(a1),d2                   ; Get class
  43.     move.w  24(a1),d3                   ; Get code
  44.     move.l  28(a1),a4                   ; Get IAddress
  45.     move.l  20(a1),d4
  46.     
  47.     move.l  _GadToolsBase,a6
  48.     jsr     GT_ReplyIMsg(a6)
  49.  
  50.     cmpi.l  #$200,d4                    ; Quit if window closed
  51.     beq     Done                        ; Remove when proper method implemented
  52.     move.l  d2,d0                       ; Get class
  53.     move.w  d3,d1                       ; Get code
  54.     move.l  a4,a0                       ; Get IAddress
  55.     jsr     ProcessWindowMainWindow     ; Call process routine
  56.     jmp     WaitHere
  57. Done:
  58.     jsr     CloseMainWindowWindow
  59. NoWindow:
  60.     jsr     FreeImages
  61. NoImages:
  62.     jsr     CloseLibs
  63. NoLibs:
  64.     rts
  65.  
  66. FirstOpt:
  67.     dc.b    'First Option',0
  68. SecondOpt:
  69.     dc.b    'Second Option',0
  70. ThirdOpt:
  71.     dc.b    'Third Option',0
  72.     cnop    0,2
  73.  
  74. TagArray:
  75.     dc.l    $8008000B,0,0               ; GTTX_Text,0,TAG_DONE
  76.  
  77.  
  78. ProcessWindowMainWindow:                ; Class in d0,code in d1,iaddress in a0 required, others are up to you.
  79.     movem.l d1-d4/a0-a6,-(sp)           ; Restore Registers
  80.     cmp.l   #$20,d0                     ; IDCMP_GADGETDOWN
  81.     bne     NotGADGETDOWN
  82.                                         ;  Gadget message, gadget is in a0
  83.     move.w  38(a0),d0                   ; Get id in d0
  84.     cmp.w   #GD_FirstGadget,d0
  85.     bne     NotFirstGadgetDown
  86.                                         ; Boolean activated, Text of gadget : 
  87.     jsr     RemoveGadgets
  88.     
  89.     movea.l MainWindowGadgets,a0
  90.     jsr     SetGadgetOn
  91.     movea.l MainWindowGadgets+4,a0
  92.     jsr     SetGadgetOff
  93.     movea.l MainWindowGadgets+8,a0
  94.     jsr     SetGadgetOff
  95.     
  96.     jsr     ReturnGadgets
  97.     lea.l   FirstOpt,a0
  98.     jsr     SetGadgetString
  99.     
  100.     jmp     MainWindowDoneMessage
  101. NotFirstGadgetDown:
  102.     cmp.w   #GD_SecondGadget,d0
  103.     bne     NotSecondGadgetDown
  104.                                         ; Boolean activated, Text of gadget : 
  105.     jsr     RemoveGadgets
  106.     
  107.     movea.l MainWindowGadgets,a0
  108.     jsr     SetGadgetOff
  109.     movea.l MainWindowGadgets+4,a0
  110.     jsr     SetGadgetOn
  111.     movea.l MainWindowGadgets+8,a0
  112.     jsr     SetGadgetOff
  113.     
  114.     jsr     ReturnGadgets
  115.     lea.l   SecondOpt,a0
  116.     jsr     SetGadgetString
  117.     
  118.     jmp     MainWindowDoneMessage
  119. NotSecondGadgetDown:
  120.     cmp.w   #GD_ThirdGadget,d0
  121.     bne     NotThirdGadgetDown
  122.                                         ; Boolean activated, Text of gadget : 
  123.     jsr     RemoveGadgets
  124.     
  125.     movea.l MainWindowGadgets,a0
  126.     jsr     SetGadgetOff
  127.     movea.l MainWindowGadgets+4,a0
  128.     jsr     SetGadgetOff
  129.     movea.l MainWindowGadgets+8,a0
  130.     jsr     SetGadgetOn
  131.     
  132.     jsr     ReturnGadgets
  133.     lea.l   ThirdOpt,a0
  134.     jsr     SetGadgetString
  135.     
  136.     jmp     MainWindowDoneMessage
  137. NotThirdGadgetDown:
  138.     jmp     MainWindowDoneMessage
  139. NotGADGETDOWN:
  140.     cmp.l   #$200,d0                    ; IDCMP_CLOSEWINDOW
  141.     bne     NotCLOSEWINDOW
  142.                                         ; CloseWindow
  143.     jmp     MainWindowDoneMessage
  144. NotCLOSEWINDOW:
  145.     cmp.l   #4,d0                       ; IDCMP_REFRESHWINDOW
  146.     bne     NotREFRESHWINDOW
  147.     movea.l MainWindow,a0
  148.     movea.l _IntuitionBase,a6
  149.     jsr     GT_BeginRefresh(a6)
  150.                                         ; Refrsh Window
  151.     move.l  #1,d0
  152.     movea.l MainWindow,a0
  153.     jsr     GT_EndRefresh(a6)
  154.     jmp     MainWindowDoneMessage
  155. NotREFRESHWINDOW:
  156.     cmp.l   #$200000,d0                 ; IDCMP_VANILLAKEY
  157.     bne     NotVANILLAKEY
  158.                                         ; Processed key press
  159.                                         ; gadgets need processing perhaps.
  160.     jmp     MainWindowDoneMessage
  161. NotVANILLAKEY:
  162. MainWindowDoneMessage:
  163.     movem.l (sp)+,d1-d4/a0-a6           ; Restore Registers
  164.     rts
  165.     
  166. SetGadgetString:                        ; Put string in a0 then call this
  167.     movea.l _GadToolsBase,a6            ; function to set text gadget.
  168.     move.l  a0,TagArray+4
  169.     movea.l MainWindowGadgets+12,a0
  170.     movea.l MainWindow,a1
  171.     movea.l #0,a2
  172.     lea     TagArray,a3
  173.     jsr     GT_SetGadgetAttrsA(a6)
  174.     rts
  175.     
  176. RemoveGadgets:
  177.     movea.l _IntuitionBase,a6
  178.     movea.l MainWindow,a0
  179.     movea.l MainWindowGList,a1
  180.     move.l  #$FFFFFFFF,d0
  181.     jsr     RemoveGList(a6)
  182.     rts
  183.  
  184. SetGadgetOn:                            ; Gadget in a0
  185.     move.w  12(a0),d0
  186.     bset    #7,d0
  187.     move.w  d0,12(a0)
  188.     rts
  189. SetGadgetOff:                            ; Gadget in a0
  190.     move.w  12(a0),d0
  191.     bclr    #7,d0
  192.     move.w  d0,12(a0)
  193.     rts
  194.  
  195. ReturnGadgets:
  196.     movea.l _IntuitionBase,a6
  197.     movea.l MainWindow,a0
  198.     movea.l MainWindowGList,a1
  199.     move.l  #50,d0
  200.     move.l  #$FFFFFFFF,d1
  201.     move.l  #0,d2
  202.     jsr     AddGList(a6)
  203.     movea.l MainWindowGList,a0
  204.     movea.l MainWindow,a1
  205.     move.l  #0,d0
  206.     move.l  #$FFFFFFFF,d1
  207.     jsr     RefreshGList(a6)
  208.     rts
  209.  
  210.     
  211.     end
  212.